package day06;
/*
* 需求: 猜数字的小游戏
* 训练目标： while（true）自造死循环+break
*
* */
import java.util.Scanner;
import java.util.Random;
public class Guessing {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Random rand = new Random();
        int num = rand.nextInt(1000)+1;
        System.out.println("作弊数字:"+num);//作弊

        while(true){//自造死循环
            System.out.println("开始猜");
            int guess = scan.nextInt();
            if(guess>num){//判断条件一
                System.out.println("大了");
            }else if(guess<num){//判断条件二
                System.out.println("小了");
            }else{//判断条件三
                System.out.println("恭喜你猜对了");
                break;//满足此条件后, 跳出循环
            }
        }
    }
}
